var app = getApp();
var c = require("../libs/common.js");
var cf = require('../libs/config.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var id = options.id;
    var that=this;
    c.ajax(
      cf.hostapi +'HospitalDetail/getHospitalDetail',
      {id:id},
      res=>{
        that.setData({ hinfo: res.data.data.hinfo, dlist: res.data.data.dlist});
        console.log(res.data.data.hinfo);
        wx.setNavigationBarTitle({
          title: res.data.data.hinfo.hos_name
      })
      }
    )
  },
  phoneclick:function(){
    var hinfo = this.data.hinfo;
    var phone = hinfo.hos_mobilephone;
    wx.makePhoneCall({
      phoneNumber: phone 
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  clickdoctor: function (e) {
    var did = e.currentTarget.dataset.did;

    wx.navigateTo({
      url: '/pages/doctordetails/doctordetails?did=' + did,
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  intoMap: function () {
    var hinfo = this.data.hinfo;
    wx.openLocation({
      latitude: parseFloat(hinfo.lat),
      longitude: parseFloat(hinfo.log),
      scale: 18,
      name: hinfo.address
    })
  }
})